using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace DanMuHelper.Logging
{
    /// <summary>
    /// 一般用于非MonoBehaviour日志，不需要InContext选项
    /// </summary>
    public static class StrLog
    {
        [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")]
        public static void LogInfo(this string s, [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "")
        {
            Echo.Write(Echo.EchoType.Info, s, callerFilePath, callerMemberName);
        }

        [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")]
        public static void LogInfoRich(this string s, string color, [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "")
        {
            Echo.WriteRich(Echo.EchoType.Info, color, s, callerFilePath, callerMemberName);
        }

        [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")]
        public static void LogInfoRich(this string s, UnityEngine.Color color, [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "")
        {
            Echo.WriteRich(Echo.EchoType.Info, "#" + UnityEngine.ColorUtility.ToHtmlStringRGB(color), s, callerFilePath, callerMemberName);
        }

        [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")]
        public static void LogInfoFormat(this string s, params object[] args)
        {
            Echo.Write(Echo.EchoType.Info, string.Format(s, args));
        }

        [Conditional("UNITY_EDITOR"), Conditional("DEVELOPMENT_BUILD")]
        public static void LogInfoFormatRich(this string s, params object[] args)
        {
            Echo.Write(Echo.EchoType.Info, string.Format(s, args));
        }

        public static void LogWarning(this string s, [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "")
        {
            Echo.Write(Echo.EchoType.Warning, s, callerFilePath, callerMemberName);
        }

        public static void LogWarningFormat(this string s, params object[] args)
        {
            Echo.Write(Echo.EchoType.Warning, string.Format(s, args));
        }

        public static void LogError(this string s, [CallerFilePath] string callerFilePath = "", [CallerMemberName] string callerMemberName = "")
        {
            Echo.Write(Echo.EchoType.Error, s, callerFilePath, callerMemberName);
        }

        public static void LogErrorFormat(this string s, params object[] args)
        {
            Echo.Write(Echo.EchoType.Error, string.Format(s, args));
        }
    }
}
